home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / misc / stats.php < prev    next >
Encoding:
PHP Script  |  2002-06-13  |  11.2 KB  |  337 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Topic Tracker module
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 6th March 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new stats;
  26.  
  27. class stats {
  28.  
  29.     var $output    = "";
  30.     var $base_url  = "";
  31.     var $html      = "";
  32.  
  33.     function stats() {
  34.     
  35.         //------------------------------------------------------
  36.         // $is_sub is a boolean operator.
  37.         // If set to 1, we don't show the "topic subscribed" page
  38.         // we simply end the subroutine and let the caller finish
  39.         // up for us.
  40.         //------------------------------------------------------
  41.     
  42.         global $ibforums, $DB, $std, $print, $skin_universal;
  43.         
  44.         $ibforums->lang    = $std->load_words($ibforums->lang, 'lang_stats', $ibforums->lang_id );
  45.  
  46.         require "./Skin/".$ibforums->skin_id."/skin_stats.php";
  47.         $this->html = new skin_stats();
  48.         
  49.         $this->base_url        = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  50.         
  51.         
  52.         
  53.         //--------------------------------------------
  54.         // What to do?
  55.         //--------------------------------------------
  56.         
  57.         switch($ibforums->input['CODE'])
  58.         {
  59.             case 'leaders':
  60.                 $this->show_leaders();
  61.                 break;
  62.             case '02':
  63.                 $this->do_search();
  64.                 break;
  65.             case 'id':
  66.                 $this->show_queries();
  67.                 break;
  68.             default:
  69.                 $this->show_today_posters();
  70.                 break;
  71.         }
  72.         
  73.         // If we have any HTML to print, do so...
  74.         
  75.         $print->add_output("$this->output");
  76.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
  77.             
  78.      }
  79.      
  80.      function show_leaders()
  81.      {
  82.          global $ibforums, $DB, $std;
  83.          
  84.          $this->output .= $this->html->page_title( $ibforums->lang['forum_leaders'] );
  85.          
  86.          //--------------------------------------------
  87.         // Work out where our super mods are at
  88.         //--------------------------------------------
  89.         
  90.         $sup_ids = array();
  91.         
  92.         $DB->query("SELECT g_id from ibf_groups WHERE g_is_supmod = 1");
  93.         
  94.         if ( $DB->get_num_rows() )
  95.         {
  96.             while ( $i = $DB->fetch_row() )
  97.             {
  98.                 $sup_ids[] = $i['g_id'];
  99.             }
  100.         }
  101.         
  102.         //--------------------------------------------
  103.         // Get our admins
  104.         //--------------------------------------------
  105.         
  106.         $admin_ids = array();
  107.         
  108.         $DB->query("SELECT id, name, email, hide_email, location, aim_name, icq_number from ibf_members WHERE mgroup='".$ibforums->vars['admin_group']."'");
  109.         
  110.         $this->output .= $this->html->group_strip( $ibforums->lang['leader_admins'] );
  111.         
  112.         while ( $member = $DB->fetch_row() )
  113.         {
  114.             $this->output .= $this->html->leader_row( $this->parse_member( $member ), $ibforums->lang['leader_all_forums'] );
  115.             
  116.             $admin_ids[] = $member['id'];
  117.         }
  118.         
  119.         $this->output .= $this->html->close_strip();
  120.         
  121.         //--------------------------------------------
  122.         // Do the bizz with the super men, er mods.
  123.         //--------------------------------------------
  124.         
  125.         $admin_ids[] = '0';
  126.         
  127.         if ( count($sup_ids) > 0 )
  128.         {
  129.             
  130.             $DB->query("SELECT id, name, email, hide_email, location, aim_name, icq_number from ibf_members WHERE mgroup IN (".implode( ',', $sup_ids ).") and id NOT IN(".implode(',', $admin_ids).")");
  131.         
  132.             if ( $DB->get_num_rows() )
  133.             {
  134.                 $this->output .= $this->html->group_strip( $ibforums->lang['leader_global'] );
  135.                 
  136.                 while ( $member = $DB->fetch_row() )
  137.                 {
  138.                     $this->output .= $this->html->leader_row( $this->parse_member( $member ), $ibforums->lang['leader_all_forums'] );
  139.                 }
  140.                 
  141.                 $this->output .= $this->html->close_strip();
  142.             }
  143.             
  144.         }
  145.         
  146.         //--------------------------------------------
  147.         // Do we have any moderators?.
  148.         //--------------------------------------------
  149.         
  150.         $DB->query("SELECT m.id, m.name, m.email, m.hide_email, m.location, m.aim_name, m.icq_number, f.id as forum_id, f.read_perms, f.name as forum_name FROM ibf_members m, ibf_forums f, ibf_moderators mod "
  151.                   ."WHERE m.id=mod.member_id and f.id=mod.forum_id");
  152.                   
  153.         $data = array();
  154.         
  155.         while ( $i = $DB->fetch_row() )
  156.         {
  157.             if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $i['read_perms'] ) )
  158.             {
  159.                 $data[] = $i;
  160.             }
  161.             else if ( $i['read_perms'] == '*' )
  162.             {
  163.                 $data[] = $i;
  164.             }
  165.         }
  166.         
  167.         //------------------------
  168.                   
  169.         if ( count($data) > 0 )
  170.         {
  171.             $mod_array = array();
  172.             
  173.             $this->output .= $this->html->group_strip( $ibforums->lang['leader_mods'] );
  174.             
  175.             foreach ( $data as $idx => $i )
  176.             {
  177.                 if ( !isset( $mod_array['member'][ $i['id'] ][ 'name' ] ) )
  178.                 {
  179.                     // Member is not already set, lets add the member...
  180.                     
  181.                     $mod_array['member'][ $i['id'] ] = array( 'name'       => $i['name'],
  182.                                                               'email'      => $i['email'],
  183.                                                               'hide_email' => $i['hide_email'],
  184.                                                               'location'   => $i['location'],
  185.                                                               'aim_name'   => $i['aim_name'],
  186.                                                               'icq_number' => $i['icq_number'],
  187.                                                               'id'         => $i['id']
  188.                                                             );
  189.                                                             
  190.                 }
  191.                 
  192.                 // Add forum..    
  193.                     
  194.                 $mod_array['forums'][ $i['id'] ][] = "<a href='".$ibforums->base_url."&act=SF&f=".$i['forum_id']."'>".$i['forum_name']."</a>";
  195.             }
  196.             
  197.             foreach( $mod_array['member'] as $id => $data )
  198.             {
  199.                 $this->output .= $this->html->leader_row( 
  200.                                                            $this->parse_member( $mod_array['member'][ $id ] ),
  201.                                                            implode( "<br>", $mod_array['forums'][ $id ] )
  202.                                                         );
  203.                                                               
  204.             }
  205.             
  206.             $this->output .= $this->html->close_strip();
  207.             
  208.         }
  209.         
  210.         $this->page_title = $ibforums->lang['forum_leaders'];
  211.         $this->nav        = array( $ibforums->lang['forum_leaders'] );
  212.         
  213.      }
  214.      
  215.      function show_queries()
  216.      {
  217.          global $ibforums, $DB, $std;
  218.          
  219.          // show DB queries in graphic format(depreciated)
  220.          // left here to stop other functions breaking
  221.          flush();
  222.          header("Content-type: image/gif");
  223.         echo base64_decode("R0lGODlhhgAfAMQAAAAAAP///+/v79/f38/Pz7+/v6+vr5+fn4+Pj4CAgHBwcGBgYFBQUEBAQDAwMCAgIBAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAhgAfAAAF/2AgjmRpnmiqrmzrvnAsz3Rt33iu7/x8mL8AgcEgiBINg2i4EAiJxtEhmlKYrCpCY5uYYXurQ8GUGAQeB8NDYFgU1oFkwopWO4/jrImKKrgLDXkwDWAsCyICC0VCCARYCQUKRggGAgwiDY54I5ABBwpFBVEGAz+AWD+JiwUGDV0FXQGwAapGia4iBwwGWgeEhSq/CwgHDpgkCwO/sLNxyGabEAgJCwSHAcaEDn4/hMPFAUhvA80KP9/GCgoFDkYApA5tv8AnBLHGAUoBlyKAzrKQYs3zx2kMPm1CDhF6UECAE4QBqiVQAqkAgIsQnOCrpm8dtoQBlNHrI7DELwJwlv8FPCYETsF/hBQYmOjsAIAHRgj9CjimYqxP/yANAQBhDKFm80aSaIZPHyEB7UQk83RgwLWnUUl0+kXIgAIHD0MKQHAJ4rpOPkeYLbArnFFZVgQkVSpiAJYiKEVcWpRLgVwzDga02cdnE1dM/LQJGOKsCFS3bpsdOOQ4G4EBDP+BRTCX7r4lDyDoK3LxYsMGAFBBwEmgNABBW1kOO3Zgdc6WEH6gLWDxYgMzKHPnW72gWy4ICzrTbWLCQBDP0KP3eT7Cr/Tr2PuZEJS9u/fv4MOLH1/3DowBTgrLQK9CALQR7lewnxEfTKcRh8SoYAD4xpQs1AkRIBncwdBMDxXdQcj/fQIU6IxVO1yWQoPmLfFeg3g0NIKESwiyGC28xTKChiCS8OEA6pWQgAMNPBCHa4A04IAVnUA4WRde5YNLjq3gaMVMGcoIgTVRbJMAVDICFMBXosXBgAOXrJjkkg40qcADLIaTJYsOiIhNAxAMgJkD+GD5wFcPIKBCAl244cxWP4AlhZrVxHSJJHYuqcWSd0ZRESEHTPTjWbMgQM6RxjwWyBnhWCHTY4qKYEwCauaogIg5HvCJEjIFkJEAnyr3UmyxQSaCJI3t4xche636GQOuZvhKF8ZUA8sAyI3BTEmHdbIrSzNBAJmvIt73zyyH/YPCbm++ZepHcgWAAFuaXjIt6wPVSkutLgXNMksRxsxiTVG/OtOrriuZy8CKw6L7EkvIsiTqJqQaZQQDd0QLpBaGNqAmv8r862/A3c7qyQKH3FppQAPwk80xCfxATMOS/uNiJweoOc2cniBQjbTGwbRmT2PklgB/Wyhw1KGmDukpNC6HKULMYpLsbRegKjHLAyuGGAcoXfTKc0pAn6GysJ0IMHQXqfAcJjsJpCSvCgWYUXU+BwhQRiYIOFH11c8FEXYuUpBNjiw1h5RH1mqHVOMYY4lNtihlIEJMXZCQcrXbBIwRxAD33Uq2J4PPMC95iNdweOKMN+7445BfFwIAOw==");
  224.         exit();
  225.      }
  226.      
  227.      
  228.      
  229.      function show_today_posters()
  230.      {
  231.          global $ibforums, $DB, $std;
  232.          
  233.          $this->output .= $this->html->page_title( $ibforums->lang['todays_posters'] );
  234.          
  235.          $this->output .= $this->html->top_poster_header();
  236.          
  237.          $time_high = time();
  238.          
  239.          $time_low = $time_high - (60*60*24);
  240.          
  241.          //--------------------------------------------
  242.         // Query the DB
  243.         //--------------------------------------------
  244.         
  245.         $DB->query("SELECT COUNT(pid) as count FROM ibf_posts WHERE post_date < $time_high and post_date > $time_low");
  246.         $todays_posts = $DB->fetch_row();
  247.         
  248.         if ($todays_posts['count'] > 0)
  249.         {
  250.         
  251.             $DB->query("SELECT COUNT(p.pid) as tpost, m.id, m.name, m.joined, m.posts FROM ibf_posts p, ibf_members m "
  252.                       ."WHERE m.id > 0 AND m.id=p.author_id and post_date < $time_high and post_date > $time_low GROUP BY p.author_id ORDER BY tpost DESC LIMIT 0,10");
  253.                       
  254.             if ( $DB->get_num_rows() )
  255.             {
  256.             
  257.                 while ($info = $DB->fetch_row())
  258.                 {
  259.                     
  260.                     $info['total_today_posts'] = $todays_posts['count'];
  261.                     
  262.                     if ($todays_posts['count'] > 0 and $info['tpost'] > 0)
  263.                     {
  264.                         $info['today_pct']     = sprintf( '%.2f',  ( $info['tpost'] / $todays_posts['count'] ) * 100  );
  265.                     }
  266.                     
  267.                     $info['joined']            = $std->get_date( $info['joined'], 'JOINED' );
  268.                     
  269.                     $this->output .= $this->html->top_poster_row( $info );
  270.                 }
  271.             }
  272.             else
  273.             {
  274.                 $this->output .= $this->html->top_poster_no_info();
  275.             }
  276.         }
  277.         else
  278.         {
  279.             $this->output .= $this->html->top_poster_no_info();
  280.         }
  281.         
  282.         $this->output .= $this->html->top_poster_footer( $todays_posts['count'] );
  283.         
  284.         $this->page_title = $ibforums->lang['top_poster_title'];
  285.         
  286.         $this->nav = array( $ibforums->lang['top_poster_title'] );
  287.         
  288.     }
  289.     
  290. //------------------------------------------------------------------------------------------------
  291.  
  292.     function parse_member( $member )
  293.     {
  294.         global $ibforums, $std;
  295.         
  296.         $member['msg_icon'] = "<a href='{$this->base_url}&act=Msg&CODE=04&MID={$member['id']}'>{$ibforums->skin['P_MSG']}</a>";
  297.             
  298.         if (!$member['hide_email'])
  299.         {
  300.             $member['email_icon'] = "<a href='{$this->base_url}&act=Mail&CODE=00&MID={$member['id']}'>{$ibforums->skin['P_EMAIL']}</a>";
  301.         }
  302.         else
  303.         {
  304.             $member['email_icon'] = ' ';
  305.         }
  306.         
  307.         if ($member['icq_number'])
  308.         {
  309.             $member['icq_icon'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=ICQ&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_ICQ]}</a>";
  310.         }
  311.         else
  312.         {
  313.             $member['icq_iconn'] = ' ';
  314.         }
  315.         
  316.         if ($member['aim_name'])
  317.         {
  318.             $member['aol_icon'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=AOL&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_AOL]}</a>";
  319.         }
  320.         else
  321.         {
  322.             $member['aol_icon'] = ' ';
  323.         }
  324.                 
  325.             return $member;
  326.         
  327.     }
  328.         
  329. }
  330.  
  331. ?>
  332.  
  333.  
  334.  
  335.  
  336.  
  337.